package roborally.exceptions;
import be.kuleuven.cs.som.annotate.*;
import roborally.model.Position;

/**
 * A class for signaling illegal positions for a board.
 * 
 * @author 	Pieter Robberechts
 * @author 	Jeroen Sanders
 */
public class InvalidPositionException extends RuntimeException {

	/**
	 * Initialize this new illegal move exception with the invalid position.
	 * 
	 * @param  	position
	 *         	The position of this new invalid position exception.
	 * @post   	...
	 * 			| new.getPosition() == position
	 */
	public InvalidPositionException(Position position) {
		this.position = position;
	}
	
	public InvalidPositionException(String message) {
		this.message = message;
	}
	
	/**
	 * Return the message registered for this invalid position exception.
	 */
	public String getMessage() {
		if(position != null)
			return "Invalid position " + this.position.toString() + "for a board.";
		if(message != null)
			return message;
		return "Invalid Position Exception!";
	}
	
	/**
	 * Returns the position registered for this invalid position exception.
	 */
	@Basic @Immutable
	public Position getPosition() {
		return position;
	}
	
	/**
	 * Variable registering the position involved in this invalid position exception.
	 */
	private Position position;
	
	/**
	 * Variable registering the message for this exception
	 */
	private String message;
	
	private static final long serialVersionUID = 204821345362718112L;

}
